home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 159 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.1 KB

  1. From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763)
  2. Message-ID: <KANZE.96Jan29095513@slsvewt.lts.sel.alcatel.de>
  3. X-Original-Date: 29 Jan 1996 08:55:12 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 29 Jan 96 10:41:59 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Why no allocator-specific delete?
  9. In-Reply-To: mtimmerm@microstar.com's message of 25 Jan 96 16:01:45 GMT
  10. Organization: SEL
  11. References: <4dvid8$460@news.bridge.net> <4e0u1s$5fv@engnews1.Eng.Sun.COM> <4e85k6$b04@noc.tor.hookup.net>
  12. Apparently-To: std-c++@ncar.ucar.edu
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMQyki+EDnX0m9pzZAQEJ3QGAl6x9CcmlbjIxxoSNLvKl6JrSjLRljrAy
  15.     VDF1UmCbtpo20Woi+3kSKAsyCODmr7eY
  16.     =h0C4
  17.  
  18. In article <4e85k6$b04@noc.tor.hookup.net> mtimmerm@microstar.com
  19. (Matt Timmermans) writes:
  20.  
  21. |> (clamage@Eng.Sun.COM (Steve Clamage))
  22.  
  23. |> |   In article 460@news.bridge.net, David Byrden
  24. |> |   <100101.2547@compuserve.com> writes:
  25. |> |   >Why, in the Septenber draft standard, is an allocator-specific verrion
  26. |> |   >of 'new' provided;
  27. |> |   >
  28. |> |   >20.1.4.4
  29. |> |   >
  30. |> |   >           new(x) T    
  31. |> |   >
  32. |> |   >    returns an X::types<T>::pointer, where x is of an 
  33. |> |   >    allocator type X
  34.  
  35. |> |   You are actually referring to the "placement new" syntax not having a
  36. |> |   corresponding "placement delete" syntax.
  37.  
  38. |> Yes, and this is very annoying.  The lack of a placement-delete makes
  39. |> placement-new nearly useless.  I can't, in fact, think of a single way that
  40. |> placement-new could be used properly.
  41.  
  42. The most common usage of placement new is simply to invoke the
  43. constructor on an arbitrary block of memory.  Since the destructor can
  44. be invoked directly, there is no need for a corresponding placement
  45. delete.
  46.  
  47. Another potential use of placement new is that described in the
  48. standard: adding a parameter to modify error handling.
  49.  
  50. Finally, if you really are using the placement to pass information
  51. concerning which arena to use, presumably each arena has a distinct
  52. address range, so you can overload operator delete to test the address
  53. range and choose the correct arena.  In this case, it is a bit of a
  54. bother that you can no longer get at the original operator delete, so
  55. you have to overload the normal operator new too.  (Luckily malloc is
  56. still available.)
  57.  
  58. |> The lack of a placement-delete is on of the many factors in C++ conspiring
  59. |> to make it absolutely impossible to make generic collections that hold
  60. |> actual objects (with constructors) instead of just pointers.
  61.  
  62. I don't understand the problem.  My containers all contain actual
  63. objects, and not just pointers.
  64. --
  65. James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
  66. GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
  67. Conseils, itudes et rialisations en logiciel orienti objet --
  68.                 -- A la recherche d'une activiti dans une region francophone
  69. ---
  70. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  71.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  72.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  73.